import { createRouter, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        redirect: '/message/type'
    },
    {
        path: '/message/type',
        name: 'MessageType',
        component: () => import('@/views/message/MessageType.vue'),
        meta: { title: '消息类型管理' }
    },
    {
        path: '/message/record',
        name: 'MessageRecord',
        component: () => import('@/views/message/MessageRecord.vue'),
        meta: { title: '消息记录查询' }
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
    // 设置页面标题
    if (to.meta.title) {
        document.title = `${to.meta.title} - 贵阳市电子政务系统`
    }
    next()
})

export default router